// 计算short , int , long , long long 所占的字节数，以及每个字节所占的位数
#include <iostream>
#include <climits>
int main(int argc, char const *argv[])
{
    using namespace std;
    short m_short = SHRT_MAX;
    int m_int = INT_MAX;
    long m_long = LONG_MAX;
    long long m_llong = LLONG_MAX;

    //sizeof operator yields size of type or of variable
    cout << "short is " << sizeof m_short << " bytes." << endl;
    cout << "int is " << sizeof (int) << " bytes." << endl;
    cout << "long is " << sizeof m_long << " bytes." << endl;
    cout << "long long is " << sizeof m_llong << " bytes." << endl;

    cout << "Maximum values:" << endl;
    cout << "int: " << m_int << endl;
    cout << "short: " << m_short << endl;
    cout << "long: " << m_long << endl;
    cout << "long long: " << m_llong << endl;

    cout << "Minimum int value: " << INT_MIN << endl;
    // 这个值在不同平台上不一样，标识每个字节所占的位数
    cout << "Bits per byte = " << CHAR_BIT << endl;

    /*
        输出：
        short is 2 bytes.
        int is 4 bytes.
        long is 8 bytes.
        long long is 8 bytes.
        Maximum values:
        int: 2147483647
        short: 32767
        long: 9223372036854775807
        long long: 9223372036854775807
        Minimum int value: -2147483648
        Bits per byte = 8
    */
    return 0;
}
